var musicApp = new Vue({
	el:"#reapp-music",
	data:{
		query:"",			// 查询关键字
		musicList:[],		// 搜索结果列表
		musicUrl:"",		// 播放歌曲地址
		musicCover:"",		// 歌曲封面地址
		musicComment:[],	// 歌曲评论列表
		mvUrl:"",			// mv地址
		isShow:false,		// 遮罩层
	},
	methods:{
		// 歌曲搜索
		searchMusic:function(keyword){
			var outer=this;
			axios.get("https://autumnfish.cn/search?keywords="+keyword).then(
				function(respone){
					//console.log(respone);
					//console.log(respone.data.result.songs);
					outer.musicList=respone.data.result.songs;
				},
				function(err){
					//console.log("searchMusic: "+err);
				}
			)
		},
		// 歌曲播放
		playingMusic:function(musicId){
			var outer=this;
			// 获取歌曲地址
			axios.get("https://autumnfish.cn/song/url?id="+musicId).then(
				function(respone){
					//console.log(respone);
					//console.log(respone.data.data[0].url);
					outer.musicUrl=respone.data.data[0].url;
				},
				function(err){
					console.log("playingMusic.url: "+err);
				}
			)
			// 获取歌曲详情
			axios.get("https://autumnfish.cn/song/detail?ids="+musicId).then(
				function(respone){
					//console.log(respone);
					//console.log(respone.data.songs[0].al.picUrl);
					outer.musicCover=respone.data.songs[0].al.picUrl;
				},
				function(err){
					console.log("playingMusic.detail: "+err);
				}
			)
			// 获取歌曲评论
			axios.get("https://autumnfish.cn/comment/hot?type=0&id="+musicId).then(
				function(respone){
					//console.log(respone);
					//console.log(respone.data.hotComments[0].content);
					//console.log(respone.data.hotComments[0].user.avatarUrl);
					//console.log(respone.data.hotComments[0].user.nickname);
					outer.musicComment=respone.data.hotComments;
				},
				function(err){
					console.log("playingMusic.hot: "+err);
				}
			)
		},
		// 播放mv
		playingMV:function(mvid){
			var outer=this;
			axios.get("https://autumnfish.cn/mv/url?id="+mvid).then(
				function(respone){
					//console.log(respone);
					console.log(respone.data.data.url);
					outer.mvUrl=respone.data.data.url;
					outer.isShow=true;
					console.log(outer.isShow);
				},
				function(err){
					console.log("playingMV:"+err);
				}
			)
		},
		// 隐藏mv
		hide:function(){
			this.isShow=false;
		}
	}
})
